#include <iostream>
#include <string>
#include <unistd.h>
#include <sys/wait.h>

void mysystem(const char* cmd)
{
    if (fork() == 0)
    {
        // child process executing execlp
        execlp(cmd, cmd, nullptr);
    }
    else
    {
        // parent wait until child finish
        wait(nullptr);
    }
}

using namespace std;
int main(int argc, char** argv)
{
    mysystem("ls");
    std::cout << "ls done\n";
    return 0;
}